$(document).ready(function () {
    layui.use('form', function () {
        var form = layui.form;
        form.render();

        getPosition();

    });
});

function getPosition() {

    var id = $('#id').val();

    ajax(
        "/admin/position/getPosition", "POST",
        { positionId: id }
        ,true, true, false
    ).done(function (returnData) {

        $("input[name='positionId']").val(returnData.positionId);
        $(":radio[name='positionType'][value='" + returnData.positionType + "']").prop("checked", true);
        $("input[name='positionParentId']").val(returnData.positionParentId);
        $("input[name='positionParentName']").val(returnData.positionParentName);
        $("input[name='positionName']").val(returnData.positionName);
        $("input[name='positionLevel']").val(returnData.positionLevel);
        $("input[name='positionSort']").val(returnData.positionSort);
        $(":radio[name='positionStatus'][value='" + returnData.positionStatus + "']").prop("checked", true);
        form.render();

    });

}

function editPosition() {

    var formJSON = $("#position-submit-form").serializeObject();

    // 编辑部门岗位
    ajax(
        "/admin/position/editPosition", "POST",
        formJSON, true, true, true
    ).done(function () {
        loadingPage("/admin/position/position");
    });

}